/*
 * @Description:
 * @Author: zoeblow
 * @Email: wangfuyuan@nnuo.com
 * @Date: 2019-12-30 13:40:41
 * @LastEditors  : zoeblow
 * @LastEditTime : 2019-12-30 15:31:20
 * @FilePath: \monitor\sdk\webpack.config.js
 */
const webpack = require("webpack");
const path = require("path");
const UglifyJSPlugin = require("uglifyjs-webpack-plugin");

var ROOT_PATH = path.resolve(__dirname);
var PUBLIC_PATH = path.resolve(__dirname, "../public");

module.exports = {
  mode: "production",
  entry: {
    //入口配置
    index: ROOT_PATH + "/cut/monitor_cut.js"
  },
  output: {
    //出口配置
    path: PUBLIC_PATH,
    filename: "monitor.min.js"
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /(node_modules)/, //排除掉node_module目录
        use: {
          loader: "babel-loader",
          options: {
            presets: [
              [
                "@babel/preset-env",
                {
                  targets: {
                    browsers: ["> 1%", "last 2 versions"]
                  }
                }
              ]
            ]
            // presets: ["env"] //转码规则
          }
        }
      }
    ]
  },
  plugins: [
    new UglifyJSPlugin({
      uglifyOptions: {
        beautify: true,
        compress: {
          drop_console: true
        }
      }
    })
  ]

  //   optimization: {
  //     minimizer: [
  //       new UglifyJSPlugin({
  //         uglifyOptions: {
  //           beautify: true,
  //           output: {
  //             comments: false
  //           },
  //           compress: {
  //             collapse_vars: true, // 内嵌定义了但是只用到一次的变量
  //             reduce_vars: true
  //           },
  //           except: ["$super", "$", "exports", "require", "html2canvas"] //排除关键字
  //         }
  //       })
  //     ]
  //   }
};
